﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WsAerolinea
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        private AerolineaBDEntities db = new AerolineaBDEntities();

        [WebMethod]
        public void Pago_Vuelo(int VueloId)
        {
            var vuelo = (from v in db.Vuelo
                         where v.Id == VueloId
                         select v).First();

            vuelo.Asientos_Diponibles -= 1;
            db.SaveChanges();
        }

        [WebMethod]
        public List<Vuelo> Lista_Vuelos()
        {

            var vuelos = (from v in db.Vuelo
                          select v).ToList();

            return vuelos;
        }

        [WebMethod]
        public List<Pais> Lista_Paises()
        {

            var paises = (from v in db.Pais
                          select v).ToList();

            return paises;
        }

        [WebMethod]
        public void Pais()
        {
            Pais pais = (from p in db.Pais
                         select p).First();
        }

        [WebMethod]
        public void Cancelar_Reserva(int VueloId)
        {
            var vuelo = (from v in db.Vuelo
                         where v.Id == VueloId
                         select v).First();

            vuelo.Asientos_Diponibles += 1;
            db.SaveChanges();
        }
    }
}